<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
    <style>
        img{
            width: 100%;
        }
    </style>
</head>
<body>
<img id="img" src="img/banner_1.jpg"/>
<script>
    var number = 1;
    function fun() {
        number++;
        if(number>3){
            number = 1;
        }
        var img = document.getElementById("img");
        img.src = "img/banner_"+number+".jpg";

    }
    setInterval(fun,2000)


</script>
</body>
</html>